/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.zrnecko.bowlingnumbers.entity;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.validator.Length;
import org.hibernate.validator.Max;
import org.hibernate.validator.Min;
import org.jboss.seam.annotations.Name;

/**
 *
 * @author zrnecko
 */
@Entity
@Name("gameBlock")
@Table(name="gameblock")
public class GameBlock implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;

	@Length(max=1000)
	private String description;

	@Min(value=0)
	@Max(value=300)
	private double average;

	@Min(value=0)
	@Max(value=1)
	private double strikePercentage;

	@Min(value=0)
	@Max(value=1)
	private double sparePercentage;

	@Min(value=0)
	@Max(value=1)
	private double onePinSparePercentage;

	@OneToMany(fetch=FetchType.LAZY)
	private Set<Game> games;

	@ManyToMany
	private Set<Tag> tags;

	public void setId(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof GameBlock)) {
			return false;
		}
		GameBlock other = (GameBlock) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "net.zrnecko.bowlingnumbers.entity.GameBlock[id=" + id + "]";
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Set<Game> getGames() {
		return games;
	}

	public void setGames(Set<Game> games) {
		this.games = games;
	}

	public double getAverage() {
		return average;
	}

	public void setAverage(double average) {
		this.average = average;
	}

	public double getStrikePercentage() {
		return strikePercentage;
	}

	public void setStrikePercentage(double strikePercentage) {
		this.strikePercentage = strikePercentage;
	}

	public double getSparePercentage() {
		return sparePercentage;
	}

	public void setSparePercentage(double sparePercentage) {
		this.sparePercentage = sparePercentage;
	}

	public double getOnePinSparePercentage() {
		return onePinSparePercentage;
	}

	public void setOnePinSparePercentage(double onePinSparePercentage) {
		this.onePinSparePercentage = onePinSparePercentage;
	}

	public Set<Tag> getTags() {
		return tags;
	}

	public void setTags(Set<Tag> tags) {
		this.tags = tags;
	}

}
